package com.ygp.basic;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

/**
 * <Description> <br>
 *
 * @author linmiaolai@sanyygp.com<br>
 * @version 1.0<br>
 * @date 2021/10/12 <br>
 */
@Slf4j(topic = "c.TestFutureTask")
public class TestFutureTask {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        FutureTask<Integer> task = new FutureTask<>(
                () -> {
                    log.debug("hello");
                    return 100;
                }
        );

        new Thread(task, "taskFutureTask").start();
        Integer result = task.get();
        log.debug("结果是：{}", result);
    }
}
